package com.jinzhi.common.controller;

import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.domain.DictDO;
import com.jinzhi.common.domain.Tree;
import com.jinzhi.common.service.DictService;
import com.jinzhi.common.utils.QrCodeUtil;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.InfoStoreDO;
import com.jinzhi.oss.service.OssService;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <pre>
 * 数据字典
 * </pre>
 * 
 * <small> 2018年3月23日 | Aron</small>
 */
@Controller
@RequestMapping("/common/erCodeFactory")
public class erCodeFactoryController extends BaseController {
    @Autowired
    private OssService ossService;
    
    @GetMapping()
    @RequiresPermissions("common:erCodeFactory")
    public String sysDict() {
        return "common/erCodeFactory/erCodeFactory";
    }

    @PostMapping("/create")
    @ResponseBody
    public Result<String> create(String value) throws IOException {
        QrCodeUtil.createQrCode(value,"D:/upload/","二维码.jpg");
        return success();
    }

    @PostMapping("/createLogo")
    @ResponseBody
    public Result<String> createLogo(String value) throws IOException {
        String logo="D://upload/logo.jpg";
        QrCodeUtil.createQrCodeLogo(value,"D:/upload/","二维码.jpg",logo);
        return success();
    }

    @GetMapping("/openErCode")
    public String openErCode(Model model){
        model.addAttribute("erCode", "../../../upload/二维码.jpg");
        return "common/erCodeFactory/openErCode";
    }
}
